# coding: utf-8

from db import db


class IndustryInfo(db.Model):
    __tablename__ = 'industry_info'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    code = db.Column(db.String(50))
    sector_link = db.Column(db.String(255, 'utf8mb4_general_ci'), info='��ҵ��飨����ʽ�')
    quotation_link = db.Column(db.String(255, 'utf8mb4_general_ci'), info='���飨ƫ����Ѷ��')
    stock_bar_url = db.Column(db.String(255, 'utf8mb4_general_ci'), info='股吧连接')
    create_time = db.Column(db.Date, info='����ʱ��')
    update_time = db.Column(db.DateTime)


class IndustrySectorFund(db.Model):
    __tablename__ = 'industry_sector_funds'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�������')
    industry_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='���code')
    open = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    close = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    high = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��߼�')
    low = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͼ�')
    preclose = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ǰ���̼�')
    volume = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ������ۼ� ��λ���ɣ�')
    amount = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ���')
    inner = db.Column(db.Integer, info='����')
    outer = db.Column(db.Integer, info='����')
    peTTM = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͨ��ֵ\t')
    pctChg = db.Column(db.Numeric(5, 2), info='�ǵ���')
    amplitude = db.Column(db.Numeric(5, 2), info='���')
    turn = db.Column(db.Numeric(5, 2), info='������')
    rising_nums = db.Column(db.Integer, info='���Ǽ���')
    decliner_nums = db.Column(db.Integer, info='�µ�����')
    flat_nums = db.Column(db.Integer, info='ƽ����')
    leading_stock = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���ǹ�Ʊ')
    main_net_inflow = db.Column(db.Numeric(10, 5), info='�����ʽ�����')
    main_inflow = db.Column(db.Numeric(10, 5), info='��������')
    main_outflow = db.Column(db.Numeric(10, 5), info='��������')
    stock_imported = db.Column(db.SmallInteger, info="板块对应的股票是否已经获取过(0-为获取;1-已获取)")
    create_time = db.Column(db.Date, info='��������')


class News(db.Model):
    __tablename__ = 'news'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    news_id = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), info='新闻编码')
    title = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='����')
    content = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='����')
    link = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='�������ӵ�ַ')
    keys = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='�ؼ���')
    industry = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='������ҵ')
    stock_code = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='��Ʊ')
    concept = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='概念')
    source = db.Column(db.Integer, info='新闻来源(0-行业导读,1-行业研究,2-产业资讯)')
    publish_time = db.Column(db.DateTime, info='����ʱ��')
    create_time = db.Column(db.DateTime, info='����ʱ��')


class StockFundamental(db.Model):
    __tablename__ = 'stock_fundamental'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    stock_name = db.Column(db.String(10, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    stock_code = db.Column(db.String(10, 'utf8mb4_0900_ai_ci'), info='ë����')
    per_earnings = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='每股收益ֵ')
    net_assets = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���ʲ�')
    net_profit = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='净利润(亿)')
    PE = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='PE')
    PB = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�о���')
    gross_margin = db.Column(db.Numeric(5, 2), info='ë����')
    net_interest_rate = db.Column(db.Numeric(8, 2), info='������')
    ROE = db.Column(db.Numeric(5, 2))
    debt_ratio = db.Column(db.Numeric(5, 2), info='��ծ��')
    UDPPS = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='每股未分配利润(元)')
    market_time = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='上市时间')
    create_time = db.Column(db.DateTime, info='����ʱ��')


class StockFundamentalCopy1(db.Model):
    __tablename__ = 'stock_fundamental_copy1'

    id = db.Column(db.Integer, primary_key=True, nullable=False, info='����id')
    stock_name = db.Column(db.String(10, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    stock_code = db.Column(db.String(10, 'utf8mb4_0900_ai_ci'), info='ë����')
    total_value = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), primary_key=True, nullable=False, info='����ֵ')
    net_assets = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���ʲ�')
    net_profit = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������')
    PE = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='PE')
    PB = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�о���')
    gross_margin = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ë����')
    net_interest_rate = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������')
    ROE = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'))
    debt_ratio = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ծ��')
    market_time = db.Column(db.Date, info='����ʱ��')
    create_time = db.Column(db.DateTime, info='����ʱ��')


class StockFund(db.Model):
    __tablename__ = 'stock_funds'
    __table_args__ = (
        db.Index('uidx_code_time', 'stock_code', 'create_time'),
    )

    id = db.Column(db.Integer, primary_key=True, info='����id')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    stock_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    open = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    close = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    high = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��߼�')
    low = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͼ�')
    average = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    preclose = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ǰ���̼�')
    volume = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ������ۼ� ��λ���ɣ�')
    amount = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ���')
    adjustflag = db.Column(db.Integer, info='��Ȩ״̬(1����Ȩ�� 2��ǰ��Ȩ��3������Ȩ��')
    tradestatus = db.Column(db.Integer, info='����״̬(1���������� 0��ͣ�ƣ�')
    total_value = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����ֵ')
    cur_value = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������ֵ\t')
    pctChg = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ǵ���')
    turn = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������')
    inner = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    outer = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    volume_ratio = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    PE = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ӯ��')
    PB = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�о���')
    main_net_inflow = db.Column(db.Numeric(13, 3), info='�����ʽ�����')
    main_inflow = db.Column(db.Numeric(13, 3), info='��������')
    main_outflow = db.Column(db.Numeric(13, 3), info='��������')
    profit_ratio = db.Column(db.Numeric(5, 2), info='��������')
    average_cost = db.Column(db.Numeric(10, 2), info='ƽ���ɱ�')
    cost_90 = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='90%�ɱ�')
    cost_70 = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='70%�ɱ�')
    concentration_90 = db.Column(db.Numeric(5, 2), info='90%���ж�')
    concentration_70 = db.Column(db.Numeric(5, 2), info='70%���ж�')
    week_day = db.Column(db.Integer, info='���ڼ�')
    create_time = db.Column(db.Date, index=True, info='����ʱ��')
    update_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='����ʱ��')


class StockFundsHolder(db.Model):
    __tablename__ = 'stock_funds_holder'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    stock_code = db.Column(db.String(10, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    stock_name = db.Column(db.String(30, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    open = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    now = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    high = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��߼�')
    low = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͼ�')
    average = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    preclose = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ǰ���̼�')
    volume = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ������ۼ� ��λ���ɣ�')
    amount = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ���')
    # adjustflag = db.Column(db.Integer, info='��Ȩ״̬(1����Ȩ�� 2��ǰ��Ȩ��3������Ȩ��')
    tradestatus = db.Column(db.Integer, info='����״̬(1���������� 0��ͣ�ƣ�')
    pctChg = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ǵ���')
    turn = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������')
    inner = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    outer = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    volume_ratio = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='����')
    PE = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ӯ��')
    PB = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�о���')
    main_net_inflow = db.Column(db.Numeric(13, 3), info='�����ʽ�����')
    week_day = db.Column(db.Integer, info='���ڼ�')
    create_time = db.Column(db.Date, index=True, info='����ʱ��')
    update_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='����ʱ��')


class StockInfo(db.Model):
    __tablename__ = 'stock_info'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    stock_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��Ʊ����')
    market = db.Column(db.String(5, 'utf8mb4_0900_ai_ci'), info='�г�����')
    bao_stock = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='baostock  ����')
    abridge = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ƴ����д')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������ҵ')
    concept = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='��������')
    stock_detail_url = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='��Ʊ�����ַ')
    create_time = db.Column(db.DateTime, info='����ʱ��')
    update_time = db.Column(db.DateTime, server_default=db.FetchedValue(), info='����ʱ��')


class StockHolders(db.Model):
    __tablename__ = 'stock_holders'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    holder_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='持股编码')
    stock_code = db.Column(db.String(10, 'utf8mb4_0900_ai_ci'), info='股票code')
    stock_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票名称')
    market = db.Column(db.String(4, 'utf8mb4_0900_ai_ci'), info='市场')
    average_price = db.Column(db.Numeric(10, 2), info="平均持仓价格")
    cur_nums = db.Column(db.Integer, info="当前持股个数")
    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class StockSpiderMark(db.Model):
    __tablename__ = 'stock_spider_mark'

    id = db.Column(db.Integer, primary_key=True, info='主键id')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票id')
    stock_funds_1 = db.Column(db.SmallInteger, info='爬虫1标识')
    stock_funds_2 = db.Column(db.SmallInteger, info='爬虫2标识')
    trading_date = db.Column(db.Date, info='股票交易日期')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class StockMarket(db.Model):
    __tablename__ = 'stock_market'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    market_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��������')
    market_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='����code')
    open = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    close = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    high = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��߼�')
    low = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͼ�')
    preclose = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ǰ���̼�')
    volume = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ������ۼ� ��λ���ɣ�')
    amount = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ���')
    inner = db.Column(db.Integer, info='����')
    outer = db.Column(db.Integer, info='����')
    peTTM = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͨ��ֵ\t')
    pctChg = db.Column(db.Numeric(5, 2), info='�ǵ���')
    amplitude = db.Column(db.Numeric(5, 2), info='���')
    turn = db.Column(db.Numeric(5, 2), info='������')
    rising_nums = db.Column(db.Integer, info='���Ǽ���')
    decliner_nums = db.Column(db.Integer, info='�µ�����')
    flat_nums = db.Column(db.Integer, info='ƽ����')
    leading_stock = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���ǹ�Ʊ')
    main_net_inflow = db.Column(db.Numeric(10, 5), info='�����ʽ�����')
    main_inflow = db.Column(db.Numeric(10, 5), info='��������')
    main_outflow = db.Column(db.Numeric(10, 5), info='��������')
    create_time = db.Column(db.Date, info='��������')


class Template(db.Model):
    __tablename__ = 'template'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�������')
    open = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    close = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���̼�')
    high = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��߼�')
    low = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='��ͼ�')
    preclose = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='ǰ���̼�')
    volume = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ������ۼ� ��λ���ɣ�')
    amount = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='�ɽ���')
    adjustflag = db.Column(db.Integer, info='��Ȩ״̬(1����Ȩ�� 2��ǰ��Ȩ��3������Ȩ��')
    tradestatus = db.Column(db.Integer, info='����״̬(1���������� 0��ͣ�ƣ�')
    peTTM = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='������ӯ��\t')
    pctChg = db.Column(db.Numeric(5, 2), info='�ǵ���')
    turn = db.Column(db.Numeric(5, 2), info='������')
    rising_nums = db.Column(db.Integer, info='���Ǽ���')
    decliner_nums = db.Column(db.Integer, info='�µ�����')
    leading_stock = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='���ǹ�Ʊ')
    main_net_inflow = db.Column(db.Numeric(10, 5), info='�����ʽ�����')
    super_large_inflow = db.Column(db.Numeric(10, 5), info='�������ʽ�����')
    large_inflow = db.Column(db.Numeric(10, 5), info='�󵥾�����')
    middle_inflow = db.Column(db.Numeric(10, 5), info='�е�������')
    small_inflow = db.Column(db.Numeric(10, 5), info='С��������')
    create_time = db.Column(db.DateTime, info='��������')


class IndustryGrowthList(db.Model):
    __tablename__ = 'industry_growth_list'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    industry_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='行业编码')
    now_price = db.Column(db.Numeric(10, 2), info='最新价格')
    volume_ratio = db.Column(db.Numeric(6, 2), info='量比')
    pctChg = db.Column(db.Numeric(5, 2), info='涨跌幅')
    turn = db.Column(db.Numeric(5, 2), info='换手率')
    rising_nums = db.Column(db.Integer, info='上涨家数')
    decliner_nums = db.Column(db.Integer, info='下跌家数')
    flat_nums = db.Column(db.Integer, info='ƽ����')
    leading_stock_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='领涨股票编码')
    leading_stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='领涨股票名称')
    main_net_inflow = db.Column(db.Numeric(20, 2), info='资金净流入')
    time_interval = db.Column(db.String(5, 'utf8mb4_0900_ai_ci'), info='时间区间')
    create_time = db.Column(db.DateTime, info='创建时间')


class IndustryStockList(db.Model):
    __tablename__ = 'industry_stock_list'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    industry_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业code')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    now_price = db.Column(db.Numeric(10, 2), info='最新价格')
    pctChg = db.Column(db.Numeric(5, 2), info='涨跌幅')
    turn = db.Column(db.Numeric(5, 2), info='换手率')
    main_net_inflow = db.Column(db.Numeric(20, 2), info='资金净流入')
    time_interval = db.Column(db.String(5, 'utf8mb4_0900_ai_ci'), info='时间区间')
    create_time = db.Column(db.DateTime, info='创建时间')


class StockPool(db.Model):
    __tablename__ = 'stock_pool'
    '''
    股票池
    '''

    id = db.Column(db.Integer, primary_key=True, info='����id')
    industry_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业code')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    now_price = db.Column(db.Numeric(10, 2), info='最新价格')
    pctChg = db.Column(db.Numeric(5, 2), info='涨跌幅')
    turn = db.Column(db.Numeric(5, 2), info='换手率')
    source = db.Column(db.Integer, info='来源(0-行业排行榜)')
    optional_state = db.Column(db.Integer, info='是否加入自选（0-未加，1-已加）')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class StockOptional(db.Model):
    __tablename__ = 'stock_optional'
    '''
    自选股
    '''

    id = db.Column(db.Integer, primary_key=True, info='����id')
    industry_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业code')
    industry_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    hold_state = db.Column(db.Integer, info='购买标识（0-未买，1-已买）')
    line_state = db.Column(db.Integer, info='生命线状态（0-未生成，1-已生成）')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')



class MarketWorkDay(db.Model):
    __tablename__ = 'market_workday'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    is_workday = db.Column(db.Integer, info='是否开市（0-不开市，1-开市）')
    create_date = db.Column(db.Date, info='创建日期')
    create_time = db.Column(db.DateTime, info='创建时间')


class ConceptRankingList(db.Model):
    __tablename__ = 'concept_ranking_list'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    concept_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    concept_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='行业编码')
    now_price = db.Column(db.Numeric(10, 2), info='最新价格')
    volume_ratio = db.Column(db.Numeric(6, 2), info='量比')
    pctChg = db.Column(db.Numeric(5, 2), info='涨跌幅')
    turn = db.Column(db.Numeric(5, 2), info='换手率')
    rising_nums = db.Column(db.Integer, info='上涨家数')
    decliner_nums = db.Column(db.Integer, info='下跌家数')
    flat_nums = db.Column(db.Integer, info='平盘家数')
    leading_stock_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='领涨股票编码')
    leading_stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='领涨股票名称')
    main_net_inflow = db.Column(db.Numeric(20, 2), info='资金净流入')
    time_interval = db.Column(db.String(5, 'utf8mb4_0900_ai_ci'), info='时间区间')
    create_date = db.Column(db.Date, info='创建日期')
    create_time = db.Column(db.DateTime, info='创建时间')


class ConceptStockList(db.Model):
    __tablename__ = 'concept_stock_list'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    concept_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业code')
    concept_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    now_price = db.Column(db.Numeric(10, 2), info='最新价格')
    pctChg = db.Column(db.Numeric(5, 2), info='涨跌幅')
    turn = db.Column(db.Numeric(5, 2), info='换手率')
    main_net_inflow = db.Column(db.Numeric(20, 2), info='资金净流入')
    time_interval = db.Column(db.String(5, 'utf8mb4_0900_ai_ci'), info='时间区间')
    create_time = db.Column(db.DateTime, info='创建时间')


class ConceptStockPool(db.Model):
    __tablename__ = 'concept_stock_pool'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    concept_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业code')
    concept_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='行业名称')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    now_price = db.Column(db.Numeric(10, 2), info='最新价格')
    pctChg = db.Column(db.Numeric(5, 2), info='涨跌幅')
    turn = db.Column(db.Numeric(5, 2), info='换手率')
    source = db.Column(db.Integer, info='来源(0-行业排行榜)')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class StockPosition(db.Model):
    __tablename__ = 'position'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    position_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票持仓id')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    average_price = db.Column(db.Numeric(6, 2), info='平均价格')
    hold_quantity = db.Column(db.Integer, info='当前持股个数')
    buy_time = db.Column(db.DateTime, info='第一次购买时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class StockPositionRecord(db.Model):
    __tablename__ = 'position_record'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    position_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票持仓id')
    order_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='订单id')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    deal_direction = db.Column(db.Integer, info='交易方向1：买入，-1：卖出')
    price = db.Column(db.Numeric(6, 2), info='成交价格')
    amount = db.Column(db.Integer, info='成交股票个数')
    create_time = db.Column(db.DateTime, info='成交时间')


class StockOrder(db.Model):
    __tablename__ = 'order'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    order_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='订单id')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    deal_direction = db.Column(db.Integer, info='交易方向1：买入，-1：卖出')
    price = db.Column(db.Numeric(6, 2), info='订单股价')
    plans = db.Column(db.Integer, info='订单里股票个数')
    order_state = db.Column(db.Integer, info='订单状态（-1：过期作废；0-新建；1-已完成；2-部分完成，3-取消）')
    update_time = db.Column(db.DateTime, info='更新时间')


class StockAccount(db.Model):
    __tablename__ = 'account'

    id = db.Column(db.Integer, primary_key=True, info='����id')
    initial_capital = db.Column(db.Numeric(10, 2), info='初始资金')
    total_funds = db.Column(db.Numeric(10, 2), info='当前总资金')
    total_market_value = db.Column(db.Numeric(10, 2), info='持股总市值')
    position_ratio = db.Column(db.Numeric(3, 2), info='资金池仓位比重')
    total_available_funds = db.Column(db.Numeric(10, 2), info='总可用资金')
    remaining_available_funds = db.Column(db.Numeric(10, 2), info='剩余可用资金')
    freeze_funds = db.Column(db.Numeric(10, 2), info='冻结资金')
    update_time = db.Column(db.DateTime, info='成交时间')


class StockLifeline(db.Model):
    __tablename__ = 'stock_lifeline'

    id = db.Column(db.Integer, primary_key=True, info='主键id')
    line_code = db.Column(db.String(50), info='阻力线编码')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    line_type = db.Column(db.Integer, info='类型（0-水平线，1-斜线）')
    line_mode = db.Column(db.Integer, info='类型（生命线模式（0-手动添加，1-放量大涨，2-放量大跌，3-顶部，4-底部）')
    point_1_time = db.Column(db.Date, info='坐标点1日期')
    point_1_price = db.Column(db.Numeric(10, 2), info='坐标点1股价')
    point_2_time = db.Column(db.Date, info='坐标点2期')
    point_2_price = db.Column(db.Numeric(10, 2), info='坐标点1股价')
    drift = db.Column(db.Numeric(5, 2), info='上下浮动率')
    line_nature = db.Column(db.Integer, info='当前属性（1-阻力，2-支撑）')
    active_state = db.Column(db.Integer, info='当前是否是激活状态（0-否，1-是）')
    effective_times = db.Column(db.Integer, info='生效次数')

    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class LifelineDetail(db.Model):
    __tablename__ = 'lifeline_detail'

    id = db.Column(db.Integer, primary_key=True, info='主键id')
    line_code = db.Column(db.String(50), info='阻力线编码')
    line_price = db.Column(db.Numeric(10, 2), info='阻力位价格')
    arrival_time = db.Column(db.DateTime, info='到达阻力位时间')
    away_time = db.Column(db.DateTime, info='离开阻力位时间')
    line_nature = db.Column(db.Integer, info='当前属性（1-阻力，2-支撑）')
    break_result = db.Column(db.Integer, info='突破结果（0-突破失败，当前线性质不变，趋势反转。1-突破成功，当前阻力线性质转变，趋势延续)')

    create_time = db.Column(db.DateTime, info='创建时间')
    update_time = db.Column(db.DateTime, info='更新时间')


class HoldersRecord(db.Model):
    '''
    持仓股票变动明细
    '''
    __tablename__ = 'holders_record'

    id = db.Column(db.Integer, primary_key=True, info='主键id')
    holder_code = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='持股编码')
    stock_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='股票名称')
    stock_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='股票编码')
    handle_nums = db.Column(db.Integer, info='当前操作股票个数')
    handle_price = db.Column(db.Numeric(6, 2), info='订单股价')
    handle_amount = db.Column(db.Numeric(10, 2), info='当前操作金额')
    remain_nums = db.Column(db.Integer, info='操作完剩余股票个数')
    handle_time = db.Column(db.DateTime, info='操作时间')
    create_time = db.Column(db.DateTime, info='创建时间')
